<html>
<title>Mobile databases</title>
<body>
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$txt= $_POST['Cat'];
echo "You are looking for ";
echo $txt;
echo "<br/>";

mysql_select_db("loc_fil", $con);

  $lat=$_POST['latitude'];
  $val=$lat-5;
  $val1=$lat+5;
  $lon=$_POST['longitude'];
  $val2=$lon-5;
  $val3=$lon+5;
  
  $res=mysql_query("SELECT * FROM $txt where Loc_latitude BETWEEN $val and $val1 and Loc_longitude BETWEEN $val2 and $val3");
$count=0;
  if ($txt=="parks")
{ ?> 
<table border="1">
<tr>
<th>P_id</th>
<th>P_Name</th>
</tr>
<?php
while($row = mysql_fetch_array($res))
 {?>
<tr>
<td><?php echo $row['P_id']?> </td>
<td><?php echo $row['P_Name']?> </td>
</tr>
 <?
 }
 ?>
</table>
<?
} 
elseif ($txt=="restaurants")
 {
   ?> 
   <table border="1">
   <tr>
   <th>R_id</th>
   <th>R_Name</th>
   </tr>
   <?php
   while($row = mysql_fetch_array($res))
     {?>
      <tr>
      <td><?php echo $row['R_id']?> </td>
      <td><?php echo $row['R_Name']?> </td>
      </tr>
       <?
      }
 ?>
</table>
<?
  }
elseif($txt=="temples")
{
  ?> 
<table border="1">
<tr>
<th>T_id</th>
<th>T_Name</th>
</tr>
<?php
while($row = mysql_fetch_array($res))
 {?>
<tr>
<td><?php echo $row['T_id']?> </td>
<td><?php echo $row['T_Name']?> </td>
</tr>
 <?
 }
 ?>
</table>
<?
}
elseif($txt=="theatres")
{$count=0;
 ?> 
<table border="1">
<tr>
<th>Th_id</th>
<th>Th_Name</th>
</tr>
<?php
while($row = mysql_fetch_array($res))
 {
   ?>
   <tr>
   <td><?php echo $row['Th_id']?> </td>
   <td><?php echo $row['Th_Name']?> </td>
   </tr>
   <?
   $count=$count+1;
   while($count%5==0)
     { ?>
       <form action="Example_theatres.php" method="post">
       <input type="submit" value="Next"/>
       </form>
       <?
       break;
     }
   }
    ?>
    </table>
    <?
  
}
else
echo "Have a nice day!";
mysql_close($con)
?>

</body>
</html>

 
  